package com.example.teacher.adapter

import android.annotation.SuppressLint
import android.app.Activity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import android.widget.ImageView
import android.widget.TextView
import com.example.teacher.R
import com.example.teacher.data.Stusign

class DetailInfoAdapter(activity: Activity, private val resourceId:Int, data:List<Stusign>)
    : ArrayAdapter<Stusign>(activity,resourceId,data) {
    @SuppressLint("ViewHolder")
    override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
        val view= LayoutInflater.from(context).inflate(resourceId,parent,false)
        val detailinfo=getItem(position)
        val stuId=view.findViewById<TextView>(R.id.stuId)
        val stuName=view.findViewById<TextView>(R.id.stuName)
        val status=view.findViewById<TextView>(R.id.status)
        val location=view.findViewById<TextView>(R.id.position)
        val iv_status=view.findViewById<ImageView>(R.id.imageViewStatus)
        if (detailinfo!=null){
            stuId.text=detailinfo.stuId
            stuName.text=detailinfo.name
            status.text=detailinfo.status
            location.text=detailinfo.position
            if (status.text=="出勤"){
                iv_status.setImageResource(R.drawable.ic_success)
            }
        }
        return view
    }
}